<template>
  <el-table :data="list" style="width: 100%; padding-top: 15px">
    <el-table-column label="订单号">
      <template slot-scope="scope">
        {{ scope.row.order_id }}
      </template>
    </el-table-column>
    <el-table-column label="订单金额" align="center">
      <template slot-scope="scope">¥ {{ scope.row.order_total }}</template>
    </el-table-column>
    <el-table-column label="订单状态" align="center">
      <template slot-scope="{ row }">
        <el-tag :type="row.order_status == 1 ? 'success' : 'danger'">
          {{ row.order_status == 1 ? '已完成' : '待支付' }}
        </el-tag>
      </template>
    </el-table-column>
    <el-table-column label="下单时间" align="center">
      <template slot-scope="{ row }">
        {{ row.order_time }}
      </template>
    </el-table-column>
  </el-table>
</template>

<script>
  import { transactionList } from '@/api/remote-search'

  export default {
    filters: {
      statusFilter(status) {
        const statusMap = {
          success: 'success',
          pending: 'danger',
        }
        return statusMap[status]
      },
      orderNoFilter(str) {
        return str.substring(0, 30)
      },
    },
    data() {
      return {
        list: null,
      }
    },
    created() {
      this.fetchData()
    },
    methods: {
      fetchData() {
        transactionList().then((response) => {
          console.log('response: ', response)
          this.list = response.data
        })
      },
    },
  }
</script>
